package com.ruoyi.web.controller.system.Fdongbei;

import com.ruoyi.common.core.domain.R;

import com.ruoyi.system.Fdongbei.domain.TbGbang;
import com.ruoyi.system.Fdongbei.domain.TbGuozhong;
import com.ruoyi.system.Fdongbei.domain.vo.BarDataVo;
import com.ruoyi.system.Fdongbei.service.DpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class DpController {
    @Autowired
    private DpService dpService;

    @PostMapping("/data")
    public R data(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        System.out.println("period:" + period);

        List<BarDataVo> barDataVo =dpService.selectCountMz(period);
        return R.ok(barDataVo);
    }




    @PostMapping("/jczcp")
    public R data1(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<BarDataVo> barDataVo =dpService.selectZcp(period);

        return R.ok(barDataVo);
    }

    @PostMapping("/cczcp")
    public R data2(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<BarDataVo> barDataVo =dpService.selectQt(period);
        return R.ok(barDataVo);
    }

    @PostMapping("/getResult")
    public R getResult(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        TbGbang tbGbang = dpService.selectGuobang(period);
        return R.ok(tbGbang);
    }


    @PostMapping("/fetchTableData")
    public R fetchTableData(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<TbGuozhong> tbGuozhong = dpService.selectJinchu(period);
        return R.ok(tbGuozhong);
    }
    @PostMapping("/dataR")
    public R dataR(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<BarDataVo> barDataVo =dpService.selectCountMzR(period);
        return R.ok(barDataVo);
    }


    @PostMapping("/jczcpr")
    public R data1r(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<BarDataVo> barDataVo =dpService.selectZcpR(period);

        return R.ok(barDataVo);
    }

    @PostMapping("/cczcpr")
    public R data2r(@RequestBody Map<String, String> request) {
        String period = request.get("period");
        List<BarDataVo> barDataVo =dpService.selectQtR(period);
        return R.ok(barDataVo);
    }
}